/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialogSerialCfg.java
 *
 * Created on 2009-11-12, 9:00:50
 */
/**
 *
 * @author Administrator
 */

package ClientDemo;

import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;

/*****************************************************************************
 *类 ：JDialogSerialCfg
 *类描述 ：串口参数配置,串口透传
 ****************************************************************************/
public class JDialogSerialCfg extends javax.swing.JDialog
{

    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
    private NativeLong m_lUserID;//用户ID
    private HCNetSDK.NET_DVR_RS232CFG_V30 m_strRs232Cfg;//232串口信息
    private HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo;//设备信息
    private HCNetSDK.NET_DVR_DECODERCFG_V30 m_stru485DecoderCfg;//485解码参数结构
    private HCNetSDK.NET_DVR_PTZCFG m_struPtzCfg;//ptz参数,用来获取解码器类型
    private boolean b485Initialed;//485串口是否已初始化
    private NativeLong m_lSerialHandle;//NET_DVR_SerialStart()的返回值 ,串口发送句柄
    private FSerialDataCallBack fSerialDataCallBack;//报警回调函数

    /*************************************************
    函数:      JDialogSerialCfg
    函数描述:	构造函数   Creates new form JDialogSerialCfg
     *************************************************/
    public JDialogSerialCfg(java.awt.Frame parent, boolean modal, NativeLong lUserID, HCNetSDK.NET_DVR_DEVICEINFO_V30 strDeviceInfo)
    {
        super(parent, modal);
        m_lUserID = lUserID;
        m_strDeviceInfo = strDeviceInfo;
        b485Initialed = false;
        m_lSerialHandle = new NativeLong(-1);
        initComponents();

        //初始化232panel
        initial232();
        //初始化485anel
        initial485();

        //初始化通道号组合框
        for (int i = 0; i < m_strDeviceInfo.byChanNum; i++)
        {
            jComboBoxChannelNumber.addItem("通道" + (i + m_strDeviceInfo.byStartChan));
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel232 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jLabel36 = new javax.swing.JLabel();
        jComboBoxPPPMode = new javax.swing.JComboBox();
        jLabel37 = new javax.swing.JLabel();
        jComboBoxRedialMode = new javax.swing.JComboBox();
        jLabel38 = new javax.swing.JLabel();
        jTextFieldUserName = new javax.swing.JTextField();
        jLabel39 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jTextFieldRemoteIP = new javax.swing.JTextField();
        jLabel42 = new javax.swing.JLabel();
        jTextFieldLocalIP = new javax.swing.JTextField();
        jLabel43 = new javax.swing.JLabel();
        jTextFieldMask = new javax.swing.JTextField();
        jLabel44 = new javax.swing.JLabel();
        jTextFieldTelNumber = new javax.swing.JTextField();
        jCheckBoxSecret = new javax.swing.JCheckBox();
        jCheckBoxRedial = new javax.swing.JCheckBox();
        jPasswordFieldPassword = new javax.swing.JPasswordField();
        jButtonSetup232 = new javax.swing.JButton();
        jButtonExit1 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jComboBox232Rate = new javax.swing.JComboBox();
        jComboBox232DataBit = new javax.swing.JComboBox();
        jComboBox232StopBit = new javax.swing.JComboBox();
        jComboBox232CheckBit = new javax.swing.JComboBox();
        jComboBox232Flow = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jComboBoxOperateMode = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jPanel485 = new javax.swing.JPanel();
        jButtonSetup485 = new javax.swing.JButton();
        jButtonExit2 = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jComboBox485Channel = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jComboBox485Rate = new javax.swing.JComboBox();
        jLabel19 = new javax.swing.JLabel();
        jComboBox485Flow = new javax.swing.JComboBox();
        jComboBox485StopBit = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        jTextFieldDecodeAddress = new javax.swing.JTextField();
        jComboBoxDecodeType = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jComboBox485CheckBit = new javax.swing.JComboBox();
        jComboBox485DataBit = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jComboBoxSerialType = new javax.swing.JComboBox();
        jComboBoxChannelNumber = new javax.swing.JComboBox();
        jPanel4 = new javax.swing.JPanel();
        jTextFieldSendData = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        jComboBoxSendInterface = new javax.swing.JComboBox();
        jButtonSend = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaMessage = new javax.swing.JTextArea();
        jButtonCreate = new javax.swing.JButton();
        jButtonDistruct = new javax.swing.JButton();
        jButtonExit3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("串口参数配置");

        jPanel232.setLayout(null);

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("窄带传输电话拨号配置"));

        jLabel36.setText("PPP模式");

        jComboBoxPPPMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "主动", "被动" }));

        jLabel37.setText("回拨模式");

        jComboBoxRedialMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "拨入者指定", "预置回拨号" }));

        jLabel38.setText("用户名");

        jLabel39.setText("密码");

        jLabel41.setText("远端IP");

        jLabel42.setText("本地IP");

        jLabel43.setText("IP掩码");

        jLabel44.setText("电话号码");

        jCheckBoxSecret.setText("数据加密");

        jCheckBoxRedial.setText("回拨");

        jPasswordFieldPassword.setText("jPasswordField1");

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel38)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextFieldUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel36)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBoxPPPMode, 0, 99, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel43, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel41, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jTextFieldMask, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                                    .addComponent(jTextFieldRemoteIP, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE))))
                        .addGap(33, 33, 33))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jCheckBoxSecret, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(96, 96, 96)))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jCheckBoxRedial, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(138, 138, 138))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel39)
                            .addComponent(jLabel42)
                            .addComponent(jLabel44)
                            .addComponent(jLabel37))
                        .addGap(23, 23, 23)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jComboBoxRedialMode, 0, 96, Short.MAX_VALUE)
                            .addComponent(jTextFieldTelNumber, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
                            .addComponent(jTextFieldLocalIP, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE)
                            .addComponent(jPasswordFieldPassword, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE))
                        .addGap(29, 29, 29))))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(jTextFieldUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel39)
                    .addComponent(jPasswordFieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel36)
                    .addComponent(jComboBoxPPPMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel37)
                    .addComponent(jComboBoxRedialMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel41)
                    .addComponent(jTextFieldRemoteIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel42)
                    .addComponent(jTextFieldLocalIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldMask, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel44)
                    .addComponent(jTextFieldTelNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel43))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxSecret)
                    .addComponent(jCheckBoxRedial))
                .addContainerGap())
        );

        jPanel232.add(jPanel9);
        jPanel9.setBounds(20, 130, 400, 200);

        jButtonSetup232.setText("设置");
        jButtonSetup232.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSetup232ActionPerformed(evt);
            }
        });
        jPanel232.add(jButtonSetup232);
        jButtonSetup232.setBounds(30, 360, 57, 23);

        jButtonExit1.setText("退出");
        jButtonExit1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExit1ActionPerformed(evt);
            }
        });
        jPanel232.add(jButtonExit1);
        jButtonExit1.setBounds(330, 360, 70, 23);

        jPanel7.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 51, 255), 1, true));
        jPanel7.setLayout(null);

        jComboBox232Rate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "50", "75", "110", "150", "300", "600", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "76800", "115.2k" }));
        jPanel7.add(jComboBox232Rate);
        jComboBox232Rate.setBounds(20, 40, 70, 21);

        jComboBox232DataBit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "5", "6", "7", "8" }));
        jPanel7.add(jComboBox232DataBit);
        jComboBox232DataBit.setBounds(100, 40, 50, 21);

        jComboBox232StopBit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));
        jPanel7.add(jComboBox232StopBit);
        jComboBox232StopBit.setBounds(180, 40, 50, 21);

        jComboBox232CheckBit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "无校验", "奇校验", "偶校验" }));
        jPanel7.add(jComboBox232CheckBit);
        jComboBox232CheckBit.setBounds(260, 40, 62, 21);

        jComboBox232Flow.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "无", "软流控", "硬流控" }));
        jPanel7.add(jComboBox232Flow);
        jComboBox232Flow.setBounds(340, 40, 62, 21);

        jLabel5.setText("流控");
        jPanel7.add(jLabel5);
        jLabel5.setBounds(340, 10, 40, 15);

        jLabel4.setText("校验");
        jPanel7.add(jLabel4);
        jLabel4.setBounds(260, 10, 40, 15);

        jLabel3.setText("停止位");
        jPanel7.add(jLabel3);
        jLabel3.setBounds(180, 10, 50, 15);

        jLabel2.setText("数据位");
        jPanel7.add(jLabel2);
        jLabel2.setBounds(100, 10, 50, 15);

        jLabel1.setText("速率");
        jPanel7.add(jLabel1);
        jLabel1.setBounds(20, 10, 40, 15);

        jComboBoxOperateMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "窄带传输", "控制台", "透明通道" }));
        jPanel7.add(jComboBoxOperateMode);
        jComboBoxOperateMode.setBounds(100, 80, 100, 21);

        jLabel6.setText("操作模式");
        jPanel7.add(jLabel6);
        jLabel6.setBounds(20, 80, 60, 15);

        jPanel232.add(jPanel7);
        jPanel7.setBounds(10, 10, 420, 330);

        jTabbedPane1.addTab("232串口配置", jPanel232);

        jPanel485.setLayout(null);

        jButtonSetup485.setText("设置当前通道");
        jButtonSetup485.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSetup485ActionPerformed(evt);
            }
        });
        jPanel485.add(jButtonSetup485);
        jButtonSetup485.setBounds(30, 360, 120, 23);

        jButtonExit2.setText("退出");
        jButtonExit2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExit2ActionPerformed(evt);
            }
        });
        jPanel485.add(jButtonExit2);
        jButtonExit2.setBounds(280, 360, 57, 23);

        jPanel10.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 70, 213), 1, true));

        jComboBox485Channel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox485ChannelActionPerformed(evt);
            }
        });

        jLabel16.setText("通道号");

        jPanel6.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true));
        jPanel6.setLayout(null);

        jComboBox485Rate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "50", "75", "110", "150", "300", "600", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "76800", "115.2k" }));
        jPanel6.add(jComboBox485Rate);
        jComboBox485Rate.setBounds(90, 30, 70, 21);

        jLabel19.setText("停止位");
        jPanel6.add(jLabel19);
        jLabel19.setBounds(30, 80, 50, 15);

        jComboBox485Flow.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "无", "软流控", "硬流控" }));
        jPanel6.add(jComboBox485Flow);
        jComboBox485Flow.setBounds(270, 80, 70, 21);

        jComboBox485StopBit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));
        jPanel6.add(jComboBox485StopBit);
        jComboBox485StopBit.setBounds(90, 80, 70, 21);

        jLabel22.setText("解码器类型");
        jPanel6.add(jLabel22);
        jLabel22.setBounds(30, 170, 70, 15);
        jPanel6.add(jTextFieldDecodeAddress);
        jTextFieldDecodeAddress.setBounds(120, 210, 100, 21);

        jPanel6.add(jComboBoxDecodeType);
        jComboBoxDecodeType.setBounds(120, 170, 100, 21);

        jLabel23.setText("解码器地址");
        jPanel6.add(jLabel23);
        jLabel23.setBounds(30, 210, 70, 15);

        jLabel17.setText("速率");
        jPanel6.add(jLabel17);
        jLabel17.setBounds(30, 30, 40, 15);

        jLabel18.setText("数据位");
        jPanel6.add(jLabel18);
        jLabel18.setBounds(210, 30, 50, 15);

        jLabel20.setText("校验");
        jPanel6.add(jLabel20);
        jLabel20.setBounds(30, 130, 40, 15);

        jComboBox485CheckBit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "无校验", "奇校验", "偶校验" }));
        jPanel6.add(jComboBox485CheckBit);
        jComboBox485CheckBit.setBounds(90, 130, 70, 21);

        jComboBox485DataBit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "5", "6", "7", "8" }));
        jPanel6.add(jComboBox485DataBit);
        jComboBox485DataBit.setBounds(270, 30, 70, 21);

        jLabel21.setText("流控");
        jPanel6.add(jLabel21);
        jLabel21.setBounds(210, 80, 50, 15);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jLabel16)
                        .addGap(42, 42, 42)
                        .addComponent(jComboBox485Channel, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jComboBox485Channel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        jPanel485.add(jPanel10);
        jPanel10.setBounds(10, 20, 430, 330);

        jTabbedPane1.addTab("RS485配置", jPanel485);

        jPanel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 51, 255), 1, true));

        jLabel24.setText("串口类型");

        jLabel25.setText("通道号");

        jComboBoxSerialType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "232", "485" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel24)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxSerialType, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(jLabel25)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxChannelNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(114, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(jComboBoxSerialType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25)
                    .addComponent(jComboBoxChannelNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("发送数据"));

        jLabel26.setText("发送接口");

        jComboBoxSendInterface.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NET_DVR_SerialSend", "NET_DVR_SendToSerialPort", "NET_DVR_SendTo232Port" }));

        jButtonSend.setText("发送");
        jButtonSend.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSendActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jTextFieldSendData, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxSendInterface, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addComponent(jButtonSend, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldSendData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonSend)
                    .addComponent(jComboBoxSendInterface, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel26))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("接收内容"));

        jTextAreaMessage.setColumns(20);
        jTextAreaMessage.setLineWrap(true);
        jTextAreaMessage.setRows(5);
        jTextAreaMessage.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTextAreaMessage);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
        );

        jButtonCreate.setText("建立通道");
        jButtonCreate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCreateActionPerformed(evt);
            }
        });

        jButtonDistruct.setText("停止通道");
        jButtonDistruct.setEnabled(false);
        jButtonDistruct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDistructActionPerformed(evt);
            }
        });

        jButtonExit3.setText("退出");
        jButtonExit3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExit3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jButtonCreate)
                        .addGap(41, 41, 41)
                        .addComponent(jButtonDistruct)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 123, Short.MAX_VALUE)
                        .addComponent(jButtonExit3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCreate)
                    .addComponent(jButtonDistruct)
                    .addComponent(jButtonExit3))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("数据透传", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /*************************************************
    函数:      "退出" 按钮单击响应函数
    函数描述:	销毁对话框
     *************************************************/
    private void jButtonExit1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExit1ActionPerformed
        this.dispose();
}//GEN-LAST:event_jButtonExit1ActionPerformed

    /*************************************************
    函数:      232  "设置" 按钮单击响应函数
    函数描述:	设置232配置参数
     *************************************************/
    private void jButtonSetup232ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSetup232ActionPerformed
        m_strRs232Cfg.struRs232.dwBaudRate = jComboBox232Rate.getSelectedIndex();
        m_strRs232Cfg.struRs232.byDataBit = (byte) jComboBox232DataBit.getSelectedIndex();
        m_strRs232Cfg.struRs232.byStopBit = (byte) jComboBox232StopBit.getSelectedIndex();
        m_strRs232Cfg.struRs232.byParity = (byte) jComboBox232CheckBit.getSelectedIndex();
        m_strRs232Cfg.struRs232.byFlowcontrol = (byte) jComboBox232Flow.getSelectedIndex();
        m_strRs232Cfg.struRs232.dwWorkMode = jComboBoxOperateMode.getSelectedIndex();
        // ppp配置信息
        m_strRs232Cfg.struPPPConfig.sUsername = (jTextFieldUserName.getText() + "\0").getBytes();
        m_strRs232Cfg.struPPPConfig.sPassword = (new String(jPasswordFieldPassword.getPassword()) + "\0").getBytes();
        m_strRs232Cfg.struPPPConfig.struRemoteIP.sIpV4 = (jTextFieldRemoteIP.getText() + "\0").getBytes();
        m_strRs232Cfg.struPPPConfig.struLocalIP.sIpV4 = (jTextFieldLocalIP.getText() + "\0").getBytes();
        m_strRs232Cfg.struPPPConfig.sLocalIPMask = (jTextFieldMask.getText() + "\0").getBytes();
        m_strRs232Cfg.struPPPConfig.sTelephoneNumber = (jTextFieldTelNumber.getText() + "\0").getBytes();

        m_strRs232Cfg.struPPPConfig.byPPPMode = (byte) jComboBoxPPPMode.getSelectedIndex();
        m_strRs232Cfg.struPPPConfig.byRedialMode = (byte) jComboBoxRedialMode.getSelectedIndex();
        m_strRs232Cfg.struPPPConfig.byDataEncrypt = (byte) (jCheckBoxSecret.isSelected() ? 1 : 0);
        m_strRs232Cfg.struPPPConfig.byRedial = (byte) (jCheckBoxRedial.isSelected() ? 1 : 0);

        m_strRs232Cfg.write();
        Pointer lpConfig = m_strRs232Cfg.getPointer();
        boolean setDVRConfigSuc = hCNetSDK.NET_DVR_SetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_SET_RS232CFG_V30,
                new NativeLong(0), lpConfig, m_strRs232Cfg.size());
        m_strRs232Cfg.read();
        if (setDVRConfigSuc != true)
        {
            JOptionPane.showMessageDialog(this, "设置232串口配置失败");
            return;
        } else
        {
            JOptionPane.showMessageDialog(this, "设置232串口配置成功");
        }
    }//GEN-LAST:event_jButtonSetup232ActionPerformed

    /*************************************************
    函数:      485 "通道号"  选项改变响应函数
    函数描述:	获取并显示对应通道的参数
     *************************************************/
    private void jComboBox485ChannelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox485ChannelActionPerformed
        if (b485Initialed)
        {
            int iChannelNumber = jComboBox485Channel.getSelectedIndex() + m_strDeviceInfo.byStartChan;
            IntByReference ibrBytesReturned = new IntByReference(0);
            boolean getDVRConfigSuc = false;
            m_stru485DecoderCfg = new HCNetSDK.NET_DVR_DECODERCFG_V30();
            m_stru485DecoderCfg.write();
            Pointer lpConfig = m_stru485DecoderCfg.getPointer();
            getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_GET_DECODERCFG_V30,
                    new NativeLong(iChannelNumber), lpConfig, m_stru485DecoderCfg.size(), ibrBytesReturned);
            m_stru485DecoderCfg.read();
            if (getDVRConfigSuc != true)
            {
                JOptionPane.showMessageDialog(this, "获取485串口参数失败");
                return;
            }
            jComboBox485Rate.setSelectedIndex(m_stru485DecoderCfg.dwBaudRate);
            jComboBox485DataBit.setSelectedIndex(m_stru485DecoderCfg.byDataBit);
            jComboBox485StopBit.setSelectedIndex(m_stru485DecoderCfg.byStopBit);
            jComboBox485Flow.setSelectedIndex(m_stru485DecoderCfg.byFlowcontrol);
            jComboBox485CheckBit.setSelectedIndex(m_stru485DecoderCfg.byParity);
            jComboBoxDecodeType.setSelectedIndex(m_stru485DecoderCfg.wDecoderType);
            jTextFieldDecodeAddress.setText(m_stru485DecoderCfg.wDecoderAddress + "");
        }
    }//GEN-LAST:event_jComboBox485ChannelActionPerformed

    /*************************************************
    函数:      485  "设置" 按钮单击响应函数
    函数描述:	设置相应485通道配置参数
     *************************************************/
    private void jButtonSetup485ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSetup485ActionPerformed
        int iChannelNumber = jComboBox485Channel.getSelectedIndex() + m_strDeviceInfo.byStartChan;
        m_stru485DecoderCfg.dwBaudRate = jComboBox485Rate.getSelectedIndex();
        m_stru485DecoderCfg.byDataBit = (byte) jComboBox485DataBit.getSelectedIndex();
        m_stru485DecoderCfg.byStopBit = (byte) jComboBox485StopBit.getSelectedIndex();
        m_stru485DecoderCfg.byParity = (byte) jComboBox485CheckBit.getSelectedIndex();
        m_stru485DecoderCfg.byFlowcontrol = (byte) jComboBox485Flow.getSelectedIndex();
        m_stru485DecoderCfg.wDecoderType = (short) jComboBoxDecodeType.getSelectedIndex();
        m_stru485DecoderCfg.wDecoderAddress = (short) Integer.parseInt(jTextFieldDecodeAddress.getText());

        m_stru485DecoderCfg.write();
        Pointer lpConfig = m_stru485DecoderCfg.getPointer();
        boolean setDVRConfigSuc = hCNetSDK.NET_DVR_SetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_SET_DECODERCFG_V30,
                new NativeLong(iChannelNumber), lpConfig, m_stru485DecoderCfg.size());
        m_stru485DecoderCfg.read();
        if (setDVRConfigSuc != true)
        {
            JOptionPane.showMessageDialog(this, "设置485串口参数失败");
            return;
        } else
        {
            JOptionPane.showMessageDialog(this, "设置485串口参数成功");
        }
    }//GEN-LAST:event_jButtonSetup485ActionPerformed

    /*************************************************
    函数:      数据透传  "发送" 按钮单击响应函数
    函数描述:	发送数据
     *************************************************/
    private void jButtonSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSendActionPerformed
        int iSendInterface = jComboBoxSendInterface.getSelectedIndex(); //发送的接口
        int iSelSerialIndex = jComboBoxChannelNumber.getSelectedIndex() + 1;//串口通道号
        int iSerialType = jComboBoxSerialType.getSelectedIndex() + 1;//串口类型

        NativeLong lSerialChan = new NativeLong(-1);//串口通道号
        if (iSerialType == 0)
        {
            //232串口作为透明通道时该值设置为0 
            lSerialChan = new NativeLong(0);
        } else
        {
            if (iSerialType == 1)
            {
                //使用485串口时有效，从1开始
                lSerialChan = new NativeLong(iSelSerialIndex);
            }
        }

        String sMessage = new String(jTextFieldSendData.getText());//要发送的消息

        if (iSendInterface == 0)
        {
            if (m_lSerialHandle.intValue() == -1)
            {
                JOptionPane.showMessageDialog(this, "请先建立透明通道");
                return;
            }
            if (!hCNetSDK.NET_DVR_SerialSend(m_lSerialHandle, lSerialChan, sMessage, sMessage.length()))
            {
                JOptionPane.showMessageDialog(this, "发送失败");
                return;
            }
        } else
        {
            if (iSendInterface == 1)
            {
                if (!hCNetSDK.NET_DVR_SendToSerialPort(m_lUserID, iSerialType, iSelSerialIndex, sMessage, sMessage.length()))
                {
                    JOptionPane.showMessageDialog(this, "发送失败");
                    return;
                }
            }
        }
    }//GEN-LAST:event_jButtonSendActionPerformed

    /*************************************************
    函数:      "退出" 按钮单击响应函数
    函数描述:	销毁对话框
     *************************************************/
    private void jButtonExit3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExit3ActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonExit3ActionPerformed

    /*************************************************
    函数:      数据透传  "建立通道" 按钮单击响应函数
    函数描述:	建立透明通道
     *************************************************/
    private void jButtonCreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCreateActionPerformed
        int iSerialType = jComboBoxSerialType.getSelectedIndex() + 1;//串口类型

        m_lSerialHandle = hCNetSDK.NET_DVR_SerialStart(m_lUserID, new NativeLong(iSerialType), fSerialDataCallBack, 0);
        if (m_lSerialHandle.intValue() == -1)
        {
            JOptionPane.showMessageDialog(this, "建立透明通道失败!");
            System.out.println(hCNetSDK.NET_DVR_GetLastError());
            return;
        } else
        {
            JOptionPane.showMessageDialog(this, "建立透明通道成功建立!");
            jButtonCreate.setEnabled(false);
            jButtonDistruct.setEnabled(true);
        }
    }//GEN-LAST:event_jButtonCreateActionPerformed

    /*************************************************
    函数:      数据透传  "停止通道" 按钮单击响应函数
    函数描述:	停止透明通道
     *************************************************/
    private void jButtonDistructActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDistructActionPerformed
        if (m_lSerialHandle.intValue() != -1)
        {
            if (!hCNetSDK.NET_DVR_SerialStop(m_lSerialHandle))
            {
                JOptionPane.showMessageDialog(this, "停止透明通道失败!");
                return;
            } else
            {
                JOptionPane.showMessageDialog(this, "停止透明通道成功!");
                jButtonCreate.setEnabled(true);
                jButtonDistruct.setEnabled(false);
            }
        }
    }//GEN-LAST:event_jButtonDistructActionPerformed

    private void jButtonExit2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExit2ActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonExit2ActionPerformed

    /*************************************************
    函数:      initial232
    函数描述:	初始化232panel
     *************************************************/
    private void initial232()
    {
        IntByReference ibrBytesReturned = new IntByReference(0);
        boolean getDVRConfigSuc = false;
        m_strRs232Cfg = new HCNetSDK.NET_DVR_RS232CFG_V30();
        m_strRs232Cfg.write();
        Pointer lpConfig = m_strRs232Cfg.getPointer();
        getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, HCNetSDK.NET_DVR_GET_RS232CFG_V30,
                new NativeLong(0), lpConfig, m_strRs232Cfg.size(), ibrBytesReturned);
        m_strRs232Cfg.read();
        if (getDVRConfigSuc != true)
        {
            JOptionPane.showMessageDialog(this, "获取232串口参数失败");
            return;
        }
        jComboBox232Rate.setSelectedIndex(m_strRs232Cfg.struRs232.dwBaudRate);
        jComboBox232DataBit.setSelectedIndex(m_strRs232Cfg.struRs232.byDataBit);
        jComboBox232StopBit.setSelectedIndex(m_strRs232Cfg.struRs232.byStopBit);
        jComboBox232CheckBit.setSelectedIndex(m_strRs232Cfg.struRs232.byParity);
        jComboBox232Flow.setSelectedIndex(m_strRs232Cfg.struRs232.byFlowcontrol);
        jComboBoxOperateMode.setSelectedIndex(m_strRs232Cfg.struRs232.dwWorkMode);

        // ppp配置信息
        String[] s = new String[2];
        s = new String(m_strRs232Cfg.struPPPConfig.sUsername).split("\0", 2);
        jTextFieldUserName.setText(s[0]);

        s = new String(m_strRs232Cfg.struPPPConfig.sPassword).split("\0", 2);
        jPasswordFieldPassword.setText(s[0]);

        s = new String(m_strRs232Cfg.struPPPConfig.struRemoteIP.sIpV4).split("\0", 2);
        jTextFieldRemoteIP.setText(s[0]);

        s = new String(m_strRs232Cfg.struPPPConfig.struLocalIP.sIpV4).split("\0", 2);
        jTextFieldLocalIP.setText(s[0]);

        s = new String(m_strRs232Cfg.struPPPConfig.sLocalIPMask).split("\0", 2);
        jTextFieldMask.setText(s[0]);

        s = new String(m_strRs232Cfg.struPPPConfig.sTelephoneNumber).split("\0", 2);
        jTextFieldTelNumber.setText(s[0]);

        jComboBoxPPPMode.setSelectedIndex(m_strRs232Cfg.struPPPConfig.byPPPMode);
        jComboBoxRedialMode.setSelectedIndex(m_strRs232Cfg.struPPPConfig.byRedialMode);

        jCheckBoxSecret.setSelected((m_strRs232Cfg.struPPPConfig.byDataEncrypt == 1) ? true : false);
        jCheckBoxRedial.setSelected((m_strRs232Cfg.struPPPConfig.byRedial == 1) ? true : false);
    }

    /*************************************************
    函数:      initial485
    函数描述:	初始化485panel
     *************************************************/
    private void initial485()
    {
        for (int i = 0; i < m_strDeviceInfo.byChanNum; i++)
        {
            jComboBox485Channel.addItem("通道" + (i + m_strDeviceInfo.byStartChan));
        }

        //获取ptz参数,初始化解码器类型组合框
        m_struPtzCfg = new HCNetSDK.NET_DVR_PTZCFG();
        if (!hCNetSDK.NET_DVR_GetPTZProtocol(m_lUserID, m_struPtzCfg))
        {
            JOptionPane.showMessageDialog(this, "获取PTZ参数失败");
            return;
        }
        String[] s = new String[2];
        for (int i = 0; i < m_struPtzCfg.dwPtzNum; i++)
        {
            s = new String(m_struPtzCfg.struPtz[i].byDescribe).split("\0", 2);
            jComboBoxDecodeType.addItem(s[0]);
        }

        b485Initialed = true;
        jComboBox485Channel.setSelectedIndex(0);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCreate;
    private javax.swing.JButton jButtonDistruct;
    private javax.swing.JButton jButtonExit1;
    private javax.swing.JButton jButtonExit2;
    private javax.swing.JButton jButtonExit3;
    private javax.swing.JButton jButtonSend;
    private javax.swing.JButton jButtonSetup232;
    private javax.swing.JButton jButtonSetup485;
    private javax.swing.JCheckBox jCheckBoxRedial;
    private javax.swing.JCheckBox jCheckBoxSecret;
    private javax.swing.JComboBox jComboBox232CheckBit;
    private javax.swing.JComboBox jComboBox232DataBit;
    private javax.swing.JComboBox jComboBox232Flow;
    private javax.swing.JComboBox jComboBox232Rate;
    private javax.swing.JComboBox jComboBox232StopBit;
    private javax.swing.JComboBox jComboBox485Channel;
    private javax.swing.JComboBox jComboBox485CheckBit;
    private javax.swing.JComboBox jComboBox485DataBit;
    private javax.swing.JComboBox jComboBox485Flow;
    private javax.swing.JComboBox jComboBox485Rate;
    private javax.swing.JComboBox jComboBox485StopBit;
    private javax.swing.JComboBox jComboBoxChannelNumber;
    private javax.swing.JComboBox jComboBoxDecodeType;
    private javax.swing.JComboBox jComboBoxOperateMode;
    private javax.swing.JComboBox jComboBoxPPPMode;
    private javax.swing.JComboBox jComboBoxRedialMode;
    private javax.swing.JComboBox jComboBoxSendInterface;
    private javax.swing.JComboBox jComboBoxSerialType;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel232;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel485;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPasswordField jPasswordFieldPassword;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextAreaMessage;
    private javax.swing.JTextField jTextFieldDecodeAddress;
    private javax.swing.JTextField jTextFieldLocalIP;
    private javax.swing.JTextField jTextFieldMask;
    private javax.swing.JTextField jTextFieldRemoteIP;
    private javax.swing.JTextField jTextFieldSendData;
    private javax.swing.JTextField jTextFieldTelNumber;
    private javax.swing.JTextField jTextFieldUserName;
    // End of variables declaration//GEN-END:variables

    /******************************************************************************
     *内部类:   FSerialDataCallBack
     *串口信息回调函数
     ******************************************************************************/
    class FSerialDataCallBack implements HCNetSDK.FSerialDataCallBack
    {

        public void invoke(NativeLong lSerialHandle, String pRecvDataBuffer, int dwBufSize, int dwUser)
        {
            //获取时间,格式化输出
            Date today = new Date();
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

            //打印时间到jTextAreaMessage
            jTextAreaMessage.append(dateFormat.format(today) + ":\n");
            //打印回调的信息到jTextAreaMessage
            jTextAreaMessage.append(pRecvDataBuffer + "\n");
        }
    }
}


